package cn.doitedu.dw_etl.utils

import cn.doitedu.dw_etl.beans.AppEventBean
import org.apache.spark.sql.Row

object EventBeanUtils {

  def row2AppEventBean(row:Row):AppEventBean = {
    val account = row.getAs[String]("account")
    val appid = row.getAs[String]("appid")
    val appversion = row.getAs[String]("appversion")
    val carrier = row.getAs[String]("carrier")
    val deviceid = row.getAs[String]("deviceid")
    val devicetype = row.getAs[String]("devicetype")
    val eventid = row.getAs[String]("eventid")
    val ip = row.getAs[String]("ip")
    val latitude = row.getAs[Double]("latitude")
    val longitude = row.getAs[Double]("longitude")
    val nettype = row.getAs[String]("nettype")
    val osname = row.getAs[String]("osname")
    val osversion = row.getAs[String]("osversion")
    val releasechannel = row.getAs[String]("releasechannel")
    val resolution = row.getAs[String]("resolution")
    val sessionid = row.getAs[String]("sessionid")
    val timestamp = row.getAs[Long]("timestamp")
    val properties = row.getAs[Map[String, String]]("properties")

    AppEventBean(
      account         ,
      appid           ,
      appversion      ,
      carrier         ,
      deviceid        ,
      devicetype      ,
      eventid         ,
      ip              ,
      latitude        ,
      longitude       ,
      nettype         ,
      osname          ,
      osversion       ,
      releasechannel  ,
      resolution      ,
      sessionid       ,
      timestamp       ,
      properties
    )

  }

}
